package src.data;

import java.util.Set;
import src.domain.User;

public class UserSRV {
	
	private static UserDAO dao;
	static {
		dao = UserDAO.getInstance();
	}
	
	public static User getByID(long idUser){
		User user=new User();
		user.setId(idUser);
		return dao.getByID(user);
	}
	
	public static User getByUserName(String userName){
		User user=new User();
		user.setUserName(userName);
		return dao.getByUserName(user);
	}
	
	public static void save(String name, String userName, String country, String city, String address,String phoneNumber,boolean active){
		User user = new User();
		user.setName(name);
		user.setUserName(userName);
		user.setCountry(country);
		user.setCity(city);
		user.setAddress(address);
		user.setPhoneNumber(phoneNumber);
		user.setActive(active);
		dao.save(user);	
	}
	
	public static void update(User user){
			dao.update(user);
	}
	
	public static void delete(long idUser){
		dao.delete(getByID(idUser));
	}
	
	public static Set<User> getAll(){
		return dao.getAll();
	}
	
	public static Set<User> getUsers(String name){
		User user=new User();
		user.setName(name);
		return dao.getUsers(user);
	}
	
	
		

}
